﻿@using System.Configuration
@using DukeNUS.FacilitiesPlanning.FPSystem

@{
    var currentUser = (ApplicationUser)Session[ApplicationSessionKeys.CurrentUser];
    var currentActiveLink = ViewBag.CurrentActiveLink;

    if (currentActiveLink == null) 
    {
        currentActiveLink = "home";
    }
    else 
    {
        if (((string)currentActiveLink).Trim() == "")
        {
            currentActiveLink = "home";
        }    
    }
}

<nav class="navbar navbar-default navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="@Url.Content("~")">
                <img class="app-logo" src="@Url.Content(ConfigurationManager.AppSettings["AppCompanyLogo"])" alt="@ConfigurationManager.AppSettings["AppName"]" />
            </a>
        </div>
        
        <ul class="nav navbar-nav navbar-right">      
            <li class="home-link @(currentActiveLink == "home"? " active" : "")"><a href="@Url.Content("~")">Home</a></li>      
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Lookup Management <span class="caret"></span></a>
              <ul class="dropdown-menu lookup-management-dropdown" role="menu">
                <li><a href="#">Area Types</a></li>
                <li><a href="#">Area Groups</a></li>
                <li><a href="#">Area Restrictions</a></li>
                <li class="divider"></li>
                <li><a href="#">Card Readers</a></li>
                <li class="divider"></li>
                <li><a href="#">Access Types</a></li>
                <li><a href="#">Applicant Types</a></li>
              </ul>
            </li>

            @if (currentUser.User.IsAdmin)
            {
                <li><a href="#user-management">User Management</a></li>    
            }
            
            <li class="dropdown">
              <a href="#currently-logged" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                  <img class="nav-icon" src="@Url.Content("~/images/user16.png")" alt="Current User" /><span class="user-name">@currentUser.User.UserName</span><span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#update-profile" data-bind="click: updateProfileMenu">
                    <img class="nav-icon" src="@Url.Content("~/images/update-profile16.png")" alt="Upate profile" /> Update Profile</a></li>
                <li><a href="#change-password" data-bind="click: changePasswordMenu">
                    <img class="nav-icon" src="@Url.Content("~/images/change-password16.png")" alt="Change password" /> Change Password</a></li>
                <li class="divider"></li>
                <li><a href="@Url.Content("~/logout")">
                    <img class="nav-icon" src="@Url.Content("~/images/logout16.png")" alt="Log out" /> Log Out</a></li>
              </ul>
            </li>
        </ul>
    </div>
</nav>

@Html.Partial("~/Views/Shared/_UpdateProfileLayout.cshtml")
@Html.Partial("~/Views/Shared/_ChangePasswordLayout.cshtml")